
window.onload = function () {
    clockStart();
}

function clockStart() {
    var today = new Date();
    var h = today.getHours()
    var m = today.getMinutes()
    var s = today.getSeconds()
    var a = document.getElementsByTagName('img');
    if (m < 10) {
        m = "0" + m.toString();
    }
    else if (m == 0) {
        m = "00";
    }

    if (s < 10) {
        s = "0" + s.toString();
    }
    else if (s == 0) {
        s = "00";
    }
    console.log(a[0].getAttribute("src"))
    if (a[0].getAttribute("src") == "head1.png") {
        if (h > 12) {
            h = h - 12;
            document.getElementById("txt_clock").innerHTML = h + ":" + m + ":" + s + " pm";
        }
        else {
            document.getElementById("txt_clock").innerHTML = h + ":" + m + ":" + s + " am";
        }
    } else { document.getElementById("txt_clock").innerHTML = h + ":" + m + ":" + s; }

    t = setTimeout("clockStart()", 500)
}
var counter = 0
function timerStart() {
    document.getElementById("timer_txt").value = counter++;
    setTimeout("timerStart()", 1000);
}